﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Description;
using WebApplication3;

namespace WebApplication3.Controllers
{
    public class HoSoController : ApiController
    {
        private CityDashboardEntities db = new CityDashboardEntities();

        [Route("api/hoso")]
        public object Get(int type, string xuly)
        {
            return db.View_HSDangGiaiQuyet_Detail_HPT.Where(x => x.type == type && x.xuly == xuly);
        }

        [Route("api/xulyhs")]
        public object GetChiTietXuLy(string mahoso)
        {
            return db.sp_ThongTinTrangXuLy_hpt(mahoso);
        }

        [Route("api/hoso")]
        public object GetHoSo(char trinhUB, char daXuLy, char dungHan)
        {
            return db.View_LoaiHS_trinhUB_DungHan_Detail_HPT.Where(x =>
                (trinhUB == '2' || (x.trinhUBND == (trinhUB == '1' ? 1 : 0))) &&
                (dungHan == '2' || (x.dung_han == (dungHan == '1' ? 1 : 0))) &&
                (daXuLy == '2' || (x.loai_hs == (daXuLy == '1' ? 1 : 0)))
                );
        }

        [Route("api/hoso")]
        public object GetHoSoBySoBn(string sobn)
        {
            return db.View_LoaiHS_trinhUB_DungHan_Detail_HPT.Where(x => x.sobnhan == sobn);
        }
        
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }


    }
}